
package com.jf.cloud.service.sysmanager.dao.impl;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jf.cloud.service.sysmanager.common.base.BaseService;
import com.jf.cloud.service.sysmanager.common.db.BaseDao;
import com.jf.cloud.service.sysmanager.dao.IPubgBaseReasonsService;
import com.jf.cloud.service.sysmanager.entity.PubgBaseReasons;


/**
 * 员工服务实现
 * 
 * @author 绝峰代码机1.0 创建时间：2018-03-31
 */
@Service("pubgBaseReasonsService")
public class PubgBaseReasonsServiceImpl extends BaseService<PubgBaseReasons, Long> implements IPubgBaseReasonsService {

	/**
	 * 日志
	 */
	private static Log log = LogFactory.getLog(PubgBaseReasonsServiceImpl.class);

	/**
	 * JPA公共DAO
	 */
	@Resource
	private BaseDao baseDao;

	/**
	 * 新增员工
	 * 
	 * @author 朱建文 创建时间：2018年4月19日 下午4:21:38
	 */
	@Transactional
	public PubgBaseReasons savePubgBaseReasons(PubgBaseReasons pubgBaseReasons) throws Exception {
		try {
			return this.baseDao.saveOrUpdate(pubgBaseReasons);
		} catch (Exception e) {
			throw new Exception("新增员工出错！", e);
		}
	}
	
	/**
	 * 修改员工
	 * 
	 * @author 朱建文 创建时间：2018年4月19日 下午4:21:46
	 */
	@Transactional
	public void updatePubgBaseReasons(PubgBaseReasons pubgBaseReasons) throws Exception {
		try {
			StringBuffer sql = new StringBuffer();
			sql.append(" UPDATE ");
			sql.append("   pubg_base_reasons ");
			sql.append(" SET ");
			sql.append("   REASON_DES = ?, USE_FLAG = ?, OPT_STAFF_ID = ?, OPT_STAFF_ACCOUNT = ?, OPT_TIME = ? ");
			sql.append(" WHERE ");
			sql.append("   ROW_ID = ? ");
			this.baseDao.safeUpdate(sql.toString(), 1, pubgBaseReasons.getReasonDes(), pubgBaseReasons.getUseFlag(),
					pubgBaseReasons.getOptStaffId(), pubgBaseReasons.getOptStaffAccount(), pubgBaseReasons.getOptTime(),
					pubgBaseReasons.getRowId());
		} catch (Exception e) {
			throw new Exception("修改员工出错！", e);
		}
	}

}
